home *** CD-ROM | disk | FTP | other *** search
- ##############################
- ## the base head is just a sphere
- ## I didn't change the name to reflect the fact that I just grabbed
- ## this from Examples/WavesWorld/canonicalRIB
- #
- set sphere(surface) plastic
- set sphere(color) {1.0 0.0 0.0}
- set sphere(radius) 1.0
- EveCmd {set sphere(zMin) -$sphere(radius)}
- EveCmd {set sphere(zMax) $sphere(radius)}
- set sphere(thetaMax) 360.0
- set sphere(xTranslate) 0
- set sphere(yTranslate) 0
- set sphere(zTranslate) 0
- set sphere(xRotate) 0
- set sphere(yRotate) 0
- set sphere(zRotate) 0
-
- #########################
- ## there are two eyes...
- ## eyes() is stuff that stays the same for both
- ## while eye() stuff is specialized for left and right
- #
- set eyes(surface) metal
- set eyes(xRotate) 0
- set eyes(xTranslate) 0
- EveCmd {set eyes(yTranslate) [expr {$sphere(radius) * .5}]}
- EveCmd {set eyes(zTranslate) [expr {$sphere(radius) * .5}]}
- set eyes(protrusion) .95
- set eyes(color) {1 1 1}
- set eyes(xRotate) 0
- set eyes(yRotate) 15
-
- set eye(volumePreservingScaleFactor) 1.5
- EveCmd {set eye(xScale) [expr 1./sqrt($eye(volumePreservingScaleFactor))]}
- EveCmd {set eye(yScale) $eye(volumePreservingScaleFactor)}
- EveCmd {set eye(zScale) [expr 1./sqrt($eye(volumePreservingScaleFactor))]}
- set eye(color) {1.0 1.0 1.0}
- set eye(percentageOfHead) .2
- EveCmd {set eye(radius) [expr {$eye(percentageOfHead) * $sphere(radius)}]}
- EveCmd {set eye(zMin) -$eye(radius)}
- EveCmd {set eye(zMax) $eye(radius)}
- set eye(thetaMax) 360.0
-
-
- set eye(xRotate) 10
- set eye(yRotate) 0
-
- ##########################
- ## there are two pupils...
- #
- EveCmd {set pupil(radius) [expr {$eye(radius)*.5}]}
- set pupil(scale) 1.0
- set pupil(color) {0 0 0}
-
- set state normal
-
- loadControlPanel controls.nib
-
- proc drawEyes {} {
-
- global sphere eyes eye pupil
-
-
- ##########
- AttributeBegin; Attribute identifier name Eyes
- Surface $eyes(surface)
- Translate eyes(xTranslate) eyes(xTranslate) eyes(zTranslate)
- Color $eyes(color)
- AttributeBegin; Attribute identifier name RightEye
- Rotate $eyes(xRotate) 1 0 0
- Rotate $eyes(yRotate) 0 1 0
- AttributeBegin; Attribute identifier name EyeBall
- Translate 0 \
- [expr {$sphere(radius)*sin(radians($eyes(xRotate)))}] \
- [expr {-$eyes(protrusion)*$sphere(radius)*cos(radians($eyes(xRotate)))}]
- # make sure this scale happens inside each eye, as it needs to be about the eye's origin
- Scale $eye(xScale) $eye(yScale) $eye(zScale)
- Rotate $eye(xRotate) 1 0 0
- Rotate $eye(yRotate) 0 1 0
- # each eye should rotate the opposite of the eyes(yRotate)
- # so that they always start off staring straight ahead
- Rotate [expr {-1*$eyes(yRotate)}] 0 1 0
- Sphere $eye(radius) [expr {-$eye(radius)}] $eye(radius) 360
- ##########
- AttributeBegin; Attribute identifier name Pupil
- set xTrans 0.0
- set yTrans 0.0
- set zTrans [expr {-$eye(radius)*.7}]
- AttributeBegin; Attribute identifier name PupilGeometry
- Translate $xTrans $yTrans $zTrans
- Scale $pupil(scale) $pupil(scale) $pupil(scale)
- Color $pupil(color)
- Sphere $pupil(radius) -$pupil(radius) $pupil(radius) 360
- endShape ;#PupilGeometry
- endShape ;#Pupil
- endShape ;#EyeBall
- endShape ;#RightEye
-
- ##########
- AttributeBegin; Attribute identifier name LeftEye
- # each eye should rotate the opposite of the eyes(xRotate) so
- # that they always start off staring straight ahead
- Rotate $eyes(xRotate) 1 0 0
- Rotate -$eyes(yRotate) 0 1 0
- ##########
- AttributeBegin; Attribute identifier name EyeBall
- Translate 0 \
- [expr {$sphere(radius)*sin(radians($eyes(xRotate)))}] \
- [expr {-$eyes(protrusion)*$sphere(radius)*cos(radians($eyes(xRotate)))}]
- # make sure this scale happens inside each eye, as it needs to be about the eye's origin
- Scale $eye(xScale) $eye(yScale) $eye(zScale)
- Rotate $eye(xRotate) 1 0 0
- Rotate $eye(yRotate) 0 1 0
- # each eye should rotate the opposite of the eyes(yRotate) so
- # that they always start off staring straight ahead
- Rotate $eyes(yRotate) 0 1 0
- Sphere $eye(radius) [expr {-$eye(radius)}] $eye(radius) 360
- ##########
- AttributeBegin; Attribute identifier name Pupil
- set xTrans 0.0
- set yTrans 0.0
- set zTrans [expr {-$eye(radius)*.7}]
- AttributeBegin; Attribute identifier name PupilGeometry
- Translate $xTrans $yTrans $zTrans
- Scale $pupil(scale) $pupil(scale) $pupil(scale)
- Color $pupil(color)
- Sphere $pupil(radius) -$pupil(radius) $pupil(radius) 360
- endShape ;#PupilGeometry
- endShape ;#Pupil
- endShape ;#EyeBall
- endShape ;#RightEye
- endShape ;#Eyes
- }
-
- # state: scared normal aggressive
- proc protoWoggle {state c xT yT zT xR yR zR} {
-
- global sphere
-
- set sphere(volumePreservingScaleFactor) 1
- if {![string compare $state scared]} { set sphere(volumePreservingScaleFactor) .8} {}
- if {![string compare $state aggressive]} { set sphere(volumePreservingScaleFactor) 1.2} {}
-
- set xS [expr 1./sqrt($sphere(volumePreservingScaleFactor))]
- set yS $sphere(volumePreservingScaleFactor)
- set zS [expr 1./sqrt($sphere(volumePreservingScaleFactor))]
-
- AttributeBegin; Attribute identifier name wwWoggle
- Surface plastic
- Color $c
- Scale $xS $yS $zS
- Translate $xT $yT $zT
- Rotate $xR 1 0 0
- Rotate $yR 0 1 0
- Rotate $zR 0 0 1
- Sphere 1 -1 1 360
- drawEyes
- endShape
- }
-
- startShape AProtoWoggle
- animatable: {protoWoggle $state \
- $sphere(color) \
- $sphere(xTranslate) $sphere(yTranslate) $sphere(zTranslate) \
- $sphere(xRotate) $sphere(yRotate) $sphere(zRotate)}
- endShape
-